<?php
require_once '../config/config.php';
require_once '../config/connexion_db.php';

$ids = isset($_GET['ids']) ? $_GET['ids'] : "";

if (isset($_POST['envoyer'])){
     if(isset($_POST['id']))      $id=$_POST['id'];
        else      $id="";
     if(isset($_POST['raison_sociale']))      $raison_sociale=$_POST['raison_sociale'];
        else      $raison_sociale="";
     if(isset($_POST['adresse']))      $adresse=$_POST['adresse'];
        else      $adresse="";
     if(isset($_POST['telephone']))      $telephone=$_POST['telephone'];
        else      $telephone="";
     if(isset($_POST['email']))      $email=$_POST['email'];
        else      $email="";
     if(isset($_POST['observations']))      $observation=$_POST['observations'];
        else      $observation="";
        if(isset($_POST['fax']))      $fax=$_POST['fax'];
        else      $fax="";
      $sql = "UPDATE entreprises SET raison_sociale='$raison_sociale', adresse='$adresse', telephone='$telephone', fax='$fax', email='$email', observations='$observation' WHERE id='$ids'";
      $envoi_requete = mysqli_query($connexion_serveur, $sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
   echo 'ENTREPRISE MODIFIE';   
  }  
?>
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>MODIFIER UNE ENTREPRISE</title>
        <link href="../bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
        <link href="../css/style.css" type="text/css" rel="stylesheet">
        
    </head>
    <body>
    
        <?php  
        
        require_once "../config/css_js_bootstrap/css_js_bootstrap.php"; 
        require_once '../config/menus/menu_principal.php';
        ?>
        
        <br>
        <div id="div3">
        <input class="btn btn-default" type="button" value="Retour à la liste des entreprises" onclick="window.location.href='../entreprises/liste_entreprises.php'">
        </div>
        <div id="div2" >
        <h2>Modifier une entreprise</h2><br>
        <?php
        $sql = "SELECT * FROM entreprises where id='$ids'";
        $envoi_requete = mysqli_query($connexion_serveur, $sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
        $resultats = mysqli_fetch_array($envoi_requete)  ?>
          </div>
        <div id="div1" >
        <form name="ajouter_contact" id="ajouter_contact" method="post" action="" enctype="multipart/form-data">
            <table>
                <tr>
                    <td class="col1">Raison sociale:</td>
                    <td class="col2"><input type="text" name="raison_sociale" id="raison_sociale" maxlength="25" size="25" value="<?php echo $resultats['raison_sociale'];?>"></td>
                </tr>
                <tr>
                    <td class="col1">Adresse</td>
                     <td class="col2"><textarea name="adresse" id="adresse" cols="40" rows="3"><?php echo $resultats['adresse'];  ?></textarea></td>
                   
                </tr>
                <tr>
                    <td class="col1">Telephone:</td>
                    <td class="col2"><input type="text" name="telephone" id="telephone" maxlength="13" size="13" value="<?php echo $resultats['telephone'];?>"></td>
                </tr>    
                <tr>
                 <td class="col1">Fax</td>
                 <td class="col2"><?php echo $resultats['fax'];  ?></td>
                </tr>
                <tr>
                    <td class="col1">Email:</td>
                    <td class="col2"><input type="text" name="email" id="email" maxlength="30" size="40" value="<?php echo $resultats['email'];?>"></td>
                </tr> 
                <tr>
                    <td class="col1">Observation:</td>
                    <td class="col2"><textarea name="observations" id="observations" cols="60" rows="5" placeholder="Observation..."><?php echo $resultats['observations'];?></textarea></td>
                </tr> 
                <tr>
                    <td class="col1"></td>
                    <td class="col2"><input type="submit" name="envoyer" value="Modifier" /></td>
                </tr>
            </table>   
            <div style="margin-left:50% ;"><a href="../entreprises/suppr_entreprises.php?id=<?php echo $resultats['id'];?>" style="color:#FF0000;" ><h4>Supprimer l'entreprise</h4></a></div>
        </form>
         </div>
        <?php
    
        ?>
       
    </body>
</html>
